/*
 * prefix_list Example program
 * Copyright 2008 Jonathan Masci
 *
 * This program is free software: you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation, either version 3 of the License, or
 * (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
 */
 
#include "prefix_list.h"

int main(int argc, char **argv) {
  uint i = 0;
  time_t startTime, endTime;
  prefix_list *plist;
  uchar *text;
  uint length;

  if (read_file(argv[1], &text, &length)) {
    printf("Unable to open file %s\n", argv[1]);
    exit(1);
  }
  time(&startTime);

  prefix_list_new(&plist, &text);
  for (i = 0; i < length; ++i) {
    if (i % 1000 == 0)
      printf("%u\n", i);
    prefix_list_add(&plist, i);
  }

  prefix_list_free(plist);
  time(&endTime);
  printf("prefix_list elapsed time: %f\n", difftime(endTime, startTime));

  return 0;
}
